package tt.dz.egobus.servicemanager.service.impl;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import tt.dz.egobus.base.dao.BaseDao;
import tt.dz.egobus.servicemanager.base.service.AbstractExtendService;
import tt.dz.egobus.servicemanager.dao.BusinessExceptionAlertDao;
import tt.dz.egobus.servicemanager.entities.BusinessExceptionAlert;
import tt.dz.egobus.servicemanager.service.BusService;
import tt.dz.egobus.servicemanager.service.BusinessExceptionAlertService;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Anson
 * @date 17-3-23
 * @name 司机绑定车辆服务
 * @since 1.0.2
 */
@Service("businessExceptionAlertServiceImpl")
public class BusinessExceptionAlertServiceImpl extends AbstractExtendService<BusinessExceptionAlert, String>
        implements BusinessExceptionAlertService {

    @Autowired
    @Qualifier("businessExceptionAlertDaoImpl")
    private BusinessExceptionAlertDao dao;




    @Override
    protected BaseDao<BusinessExceptionAlert, String> getSelfDao() {
        return dao;
    }

    @Override
    @Transactional
    public boolean isExistValidateBusUnDeal(String busNo) {
        if (StringUtils.isBlank(busNo)) {
            return false;
        }
        Map<String, Object> param = new HashMap<String, Object>();
        param.put("busNo", busNo);
        String hql = BusinessExceptionAlert.IS_EXIST_VALIDATE_BUS_UNDEAL;
        int count = this.dao.findCount(hql, param);
        return count > 0;
    }
}
